<%@page import="dao.Knowledgepoint"%>
<%@page import="beans.KnowledgePointbean"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
		    + request.getServerName() + ":" + request.getServerPort()
		    + path + "/";
%>
<%!int transerToInt(String chapterid) {
	return Integer.parseInt(chapterid.substring(2));
    }

    String getType(String typeString) {
	if ("normal".equals(typeString)) {
	    return "普通知识点";
	} else if ("difficult".equals(typeString)) {
	    return "难点";
	} else if ("important".equals(typeString)) {
	    return "重点";
	}else{
	    return "";
	}
    }%>
<%
    String idString;
    KnowledgePointbean knowledgePointbean = null;
    Knowledgepoint knowledgepoint = null;
    if (request.getQueryString() != null) {
		idString = request.getParameter("knowledgeid");
		int knowledgeid = Integer.parseInt(idString);
		knowledgePointbean = new KnowledgePointbean();
		knowledgepoint = knowledgePointbean
			.getKnowledgepointById(knowledgeid);
    }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>知识点</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
body {
	font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica,
		sans-serif;
	color: #4f6b72;
	text-align: center;
	background: #E6EAE9;
}

#container {
	margin-left: auto;
	margin-right: auto;
	width: 800px;
	height: 700px;
	background: #f8f8f8;
	display: block;
	vertical-align: middle;
}

.ele {
	margin-top: 15px;
	margin-botton: 15px;
	text-align: center;
	width: 100%;
	display: block;
	vertical-align: middle;
}
</style>
</head>
<body>
	<h2>知识点</h2>
	<div id="container">
		<c:choose>
			<c:when test="<%=knowledgepoint ==null %>">
				<c:out value="要找的知识点不存在"></c:out>
			</c:when>
			<c:otherwise>
				<div class="ele">
					<h3>
						<%=knowledgepoint.getTitle()%></h3>
				</div>
				<div class="ele">
					<label> 所属章节： </label> <a
						href="./common/chapter.jsp?chapterid=<%=knowledgepoint.getChapterid()%>">第&nbsp<%=transerToInt(knowledgepoint.getChapterid())%>&nbsp;章</a>
					<br>
					<label> 知识点类型： </label><%=getType(knowledgepoint.getKnowledgetype())%>
				</div>
				<div class="ele">
					<label> 知识点介绍： </label><br>
					<%=knowledgepoint.getDescription()%>
				</div>
				<div class="ele">
					<label> 实例： </label>
					<c:if test="<%=knowledgepoint.getExample() !=null %>">
						<c:out value="<%=knowledgepoint.getExample() %>"></c:out>
						<br>
					</c:if>
					<c:if test="<%=knowledgepoint.getPath() !=null %>">
						<img alt="实例" src=".<%=knowledgepoint.getPath()%>">
					</c:if>
					<c:if test="<%=knowledgepoint.getPath() ==null && knowledgepoint.getExample() ==null %>">
						<c:out value="略"></c:out>
					</c:if>
				</div>
			</c:otherwise>
		</c:choose>
	</div>
</body>
</html>
